package com.zzyl.service.impl;

import cn.hutool.core.bean.BeanUtil;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.zzyl.base.PageResponse;
import com.zzyl.dto.AlertDataHandleDto;
import com.zzyl.dto.AlertDataPageQueryDto;
import com.zzyl.entity.AlertData;
import com.zzyl.mapper.AlertDateMapper;
import com.zzyl.service.AlertDateService;
import com.zzyl.vo.AlertDataVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;

/**
 * @Description AlertDateServiceImpl
 * @Author xiao  xun
 * @Date 2024-09-15
 */
@Service
public class AlertDateServiceImpl implements AlertDateService {

    @Autowired
    private AlertDateMapper alertDateMapper;
    /**
     * 分页查询报警数据
     * @param alertDataPageQueryDto
     * @return
     */
    @Override
    public PageResponse<AlertDataVo> pageSelect(AlertDataPageQueryDto alertDataPageQueryDto) {
        PageHelper.startPage(alertDataPageQueryDto.getPageNum(),alertDataPageQueryDto.getPageSize());


        Page<AlertDataVo> page = alertDateMapper.pageSelect(alertDataPageQueryDto);
        PageResponse<AlertDataVo> alertDataVoPageResponse = new PageResponse<>(page);
        alertDataVoPageResponse.setRecords(page.getResult());
        return alertDataVoPageResponse;
    }
    /**
     * 处理设备报警数据
     * @param
     */
    @Override
    public void handleAlertData(AlertDataHandleDto alertDataHandleDto) {
       // AlertData alertData = BeanUtil.toBean(alertDataHandleDto, AlertData.class);
        alertDateMapper.handleAlertData(alertDataHandleDto);
    }
}
